package com.easygoods.request;

import com.bestvike.stone.spring.exception.AssertUtils;
import com.bestvike.stone.spring.rest.IRequest;
import com.easygoods.enums.Channel;
import lombok.Data;

import java.util.function.Consumer;

/**
 * Created by 许崇雷 on 2018-12-25.
 */
@Data
public class ExternalRegisterRequest implements IRequest, Consumer<String> {
    private Channel channel;
    private String openId;
    private String mobile;//手机号
    private String verifyCode;//验证码
    private String nickName;//昵称
    private String refMemberId;//上级
    private String avatarUrl;//头像 url

    @SuppressWarnings({"Duplicates","ffdfds"})

    public void assertValid() {
        AssertUtils.notNull(this.channel, "channel");
        AssertUtils.hasText(this.openId, "openid");
        AssertUtils.hasText(this.mobile, "mobile");
        AssertUtils.isTrue(this.mobile.length() == 11, "手机号格式错误");
        AssertUtils.hasText(this.verifyCode, "verifyCode");
        AssertUtils.hasText(this.nickName, "nickName");
    }

    /**
     * Performs this operation on the given argument.
     *
     * @param s the input argument
     */
    @Override
    public void accept(String s) {

    }
}
